/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package cn.knet.sp.ncrm.modules.customer.potentialcontactor.entity;

import com.fasterxml.jackson.annotation.JsonFormat;

import org.hibernate.validator.constraints.Length;

import java.util.Date;

import javax.validation.constraints.NotNull;

import cn.knet.sp.ncrm.common.persistence.DataEntity;
import cn.knet.sp.ncrm.common.utils.IdGen;

/**
 * 潜在客户主表Entity
 * @author gehaiyang
 * @version 2015-08-24
 */
public class PotentialContactor extends DataEntity<PotentialContactor> {
	
	private static final long serialVersionUID = 1L;
	private Long version = 0L;		// version
	private Date dateCreated;		// date_created
	private String detail;		// 详细信息
	private String email;		// email
	private String identity;		// 身份
	private Date lastUpdated;		// 更新时间
	private String name;		// 姓名
	private String potentialCustomerId;		// 潜在客户id
	private String telephone;		// 电话
	private String mobile;		// 手机
	private String wechat;		// 微信
	private String qq;		// QQ
	
	public PotentialContactor() {
		super();
	}

	public PotentialContactor(String id){
		super(id);
	}

	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}
	
	@Length(min=0, max=64, message="详细信息长度必须介于 0 和 64 之间")
	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}
	
	@Length(min=0, max=50, message="email长度必须介于 0 和 50 之间")
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	@Length(min=0, max=20, message="身份长度必须介于 0 和 20 之间")
	public String getIdentity() {
		return identity;
	}

	public void setIdentity(String identity) {
		this.identity = identity;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getLastUpdated() {
		return lastUpdated;
	}

	public void setLastUpdated(Date lastUpdated) {
		this.lastUpdated = lastUpdated;
	}
	
	@Length(min=1, max=100, message="姓名长度必须介于 1 和 100 之间")
	@NotNull
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Length(min=1, max=64, message="潜在客户id长度必须介于 1 和 64 之间")
	public String getPotentialCustomerId() {
		return potentialCustomerId;
	}

	public void setPotentialCustomerId(String potentialCustomerId) {
		this.potentialCustomerId = potentialCustomerId;
	}
	
	@Length(min=0, max=100, message="电话长度必须介于 0 和 100 之间")
	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	
	@Length(min=0, max=100, message="手机长度必须介于 0 和 100 之间")
	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	@Length(min=0, max=100, message="微信长度必须介于 0 和 100 之间")
	public String getWechat() {
		return wechat;
	}

	public void setWechat(String wechat) {
		this.wechat = wechat;
	}
	
	@Length(min=0, max=100, message="QQ长度必须介于 0 和 100 之间")
	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}


	/**
	 * 插入之前执行方法，需要手动调用
	 */
	@Override
	public void preInsert(){
		// 不限制ID为UUID，调用setIsNewRecord()使用自定义ID
		if (!this.isNewRecord){
			setId(IdGen.uuid());
		}

		this.dateCreated = new Date();
		this.lastUpdated = new Date();
	}

	/**
	 * 更新之前执行方法，需要手动调用
	 */
	@Override
	public void preUpdate(){
		this.lastUpdated = new Date();
	}
	
}